package com.orange.score.network;

import android.util.Log;
import com.orange.score.constants.LanguageType;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

public class RepositoryNetworkRequest
{
  public static final int INDEX_REPOSITORY_CONTINENT_COUNT = 2;
  public static final int INDEX_REPOSITORY_CONTINENT_ID = 0;
  public static final int INDEX_REPOSITORY_CONTINENT_NAME = 1;
  public static final int INDEX_REPOSITORY_COUNTRY_CONTINENT_ID = 1;
  public static final int INDEX_REPOSITORY_COUNTRY_COUNT = 3;
  public static final int INDEX_REPOSITORY_COUNTRY_ID = 0;
  public static final int INDEX_REPOSITORY_COUNTRY_NAME = 2;
  public static final int INDEX_REPOSITORY_CUP_GROUP_COUNT = 3;
  public static final int INDEX_REPOSITORY_CUP_GROUP_GROUP_ID = 2;
  public static final int INDEX_REPOSITORY_CUP_GROUP_LEAGUE_ID = 0;
  public static final int INDEX_REPOSITORY_CUP_GROUP_SEASON = 1;
  public static final int INDEX_REPOSITORY_LEAGUE_COUNT = 6;
  public static final int INDEX_REPOSITORY_LEAGUE_COUNTRY_ID = 1;
  public static final int INDEX_REPOSITORY_LEAGUE_ID = 0;
  public static final int INDEX_REPOSITORY_LEAGUE_NAME = 2;
  public static final int INDEX_REPOSITORY_LEAGUE_SCHEDULE_CURRENT_ROUND = 0;
  public static final int INDEX_REPOSITORY_LEAGUE_SEASON_LIST = 5;
  public static final int INDEX_REPOSITORY_LEAGUE_SHORTNAME = 3;
  public static final int INDEX_REPOSITORY_LEAGUE_TYPE = 4;
  private static final int LEVEL_FIELD = 3;
  private static final int LEVEL_RECORD = 2;
  private static final int LEVEL_SEGMENT = 1;
  public static final int SEGMENT_REPOSITORY_CONTINENT = 0;
  public static final int SEGMENT_REPOSITORY_COUNTRY = 1;
  public static final int SEGMENT_REPOSITORY_CUP_SCHEDULE_COUNT = 3;
  public static final int SEGMENT_REPOSITORY_CUP_SCHEDULE_GROUP_INFO = 0;
  public static final int SEGMENT_REPOSITORY_CUP_SCHEDULE_GROUP_POINTS = 1;
  public static final int SEGMENT_REPOSITORY_CUP_SCHEDULE_MATCH_RESULT = 2;
  public static final int SEGMENT_REPOSITORY_LEAGUE = 2;
  public static final int SEGMENT_REPOSITORY_LEAGUE_SCHEDULE_COUNT = 2;
  public static final int SEGMENT_REPOSITORY_LEAGUE_SCHEDULE_ROUND_DETAIL = 1;
  public static final int SEGMENT_REPOSITORY_LEAGUE_SCHEDULE_TOTAL_ROUND = 0;
  public static final int SEGMENT_REPOSITORY_NUM = 3;
  public static final String SEP_FIELD = "\\^";
  public static final String SEP_RECORD = "\\!";
  public static final String SEP_SEGMENT = "\\$\\$";
  private static final String TAG = ScoreNetworkRequest.class.getName();

  public static String[] getAllRepository(LanguageType paramLanguageType)
  {
    Object[] arrayOfObject = new Object[1];
    arrayOfObject[0] = Integer.valueOf(paramLanguageType.intValue());
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/InfoIndex.aspx?lang=%d", arrayOfObject), 1);
  }

  public static String[] getRepositoryGroupInfo(String paramString1, String paramString2)
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = paramString1;
    arrayOfObject[1] = paramString2;
    return scoreHttpGet(String.format("http://bf.bet007.com/Phone/cupsaicheng.aspx?id=%s&season=%s", arrayOfObject), 1);
  }

  public static String[] getRepositoryRoundInfo(String paramString1, String paramString2)
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = paramString1;
    arrayOfObject[1] = paramString2;
    return scoreHttpGet(String.format("http://bf.bet007.com/phone/SaiCheng.aspx?ID=%s&Season=%s", arrayOfObject), 1);
  }

  public static String httpGet(String paramString)
  {
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
    HttpGet localHttpGet = new HttpGet(paramString);
    BasicResponseHandler localBasicResponseHandler = new BasicResponseHandler();
    String str = null;
    try
    {
      Log.d(TAG, "Send http request: " + paramString);
      str = (String)localDefaultHttpClient.execute(localHttpGet, localBasicResponseHandler);
      Log.d(TAG, "Get http response: " + str);
      return str;
    }
    catch (Exception localException)
    {
      Log.e(TAG, "catch exception while send http request " + localException.toString(), localException);
    }
  }

  public static String[] scoreHttpGet(String paramString, int paramInt)
  {
    Object localObject;
    String str = httpGet(paramString);
    if (str == null)
    {
      localObject = null;
      return localObject;
    }
    String[] arrayOfString = (String[])null;
    if (paramInt == 1)
      arrayOfString = str.split("\\$\\$");
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
            localObject = arrayOfString;
          if (paramInt != 2)
            break;
          arrayOfString = str.split("\\!");
        }
        if (paramInt != 3)
          break;
        arrayOfString = str.split("\\^");
      }
      Log.e(TAG, "Score Http Get But incorrect Level");
    }
  }
}